import React from 'react'
import ReactDOM from 'react-dom'
import { connect } from 'react-redux'
import config from 'config';
import 'styles/third-consumption/third-consumption.scss'

class MyFlightOrder extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      iFrameHeight: 'calc(100vh - 127px)'
    };
  }

  render() {
    const { iFrameHeight } = this.state;
    const { access_token } = this.props.authToken;
    const zxHost = config.zxHosts[location.host] || config.zxHost;
    const realmId = config.realmIds[location.host] || config.realmId;
    const timeStamp = new Date().getTime();
    const targetUrl = `${zxHost}/?vendorCode=airPlane&pageType=orderList&access_token=${access_token}&realmId=${realmId}&timeStamp=${timeStamp}`;
    console.log('----我的机票： 甄选-----', targetUrl)
    return (

        <iframe
          style={{width: '100%', height: iFrameHeight, overflow: 'visible'}}
          onLoad={() => {
            // const obj = ReactDOM.findDOMNode(this);
            // this.setState({
            //   "iFrameHeight":  obj.contentWindow.document.body.scrollHeight + 'px'
            // });
          }}
          ref="iframe"
          sandbox="allow-scripts allow-forms allow-same-origin"
          src={targetUrl}
          width="100%"
          height={iFrameHeight}
          scrolling="no"
          frameBorder="0"
        />

    );
  }

}

function mapStateToProps(state) {
  return {
    user: state.login.user,
    authToken: state.main.authToken
  };
}

export default connect(mapStateToProps)(MyFlightOrder);
